package cn.com.miao.lynx.common.data.jpa.config;

import com.querydsl.jpa.impl.JPAQueryFactory;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;

import javax.persistence.EntityManager;

/**
 * JpaAutoConfig
 *
 * @title: JpaAutoConfig
 * @description:
 * @author: dengmiao
 * @create: 2019-12-23 16:32
 **/
@Slf4j
@AllArgsConstructor
@EnableJpaAuditing
@Configuration
public class JpaAutoConfig {

    private final EntityManager entityManager;

    /**
     * 查询工厂实体
     * @return 查询工厂
     */
    @Bean
    public JPAQueryFactory jpaQueryFactory() {
        return new JPAQueryFactory(entityManager);
    }
}
